package cn.gg.benchmark.test;
import java.util.Random;

public class Case implements IExecuable, Runnable {

	private String s = null;
	private Suite container;

	public void setContainer(Suite container) {
		this.container = container;
	}

	public void execute() {
		Thread thread = new Thread(this);
		thread.start();
	}

	public void init() {
		Random rad = new Random();
		s = "This is case " + rad.nextInt(100);
		rad = null;
	}

	public void release() {
		s = null;
		if (container != null) {
			container.restartThread();
			container = null;
		}
	}

	public synchronized void run() {
		for (int i = 0; i < 5; i++) {
			System.out.println(s);
			try {
				Thread.sleep(50L);
			} catch (InterruptedException e) {
			}
		}
		release();
	}

}
